﻿<MDataTable Headers="_headers"
            Items="_desserts"
            ItemKey="r=>r.Name"
            SortBy="nameof(Dessert.Name)"
            GroupBy="nameof(Dessert.Category)"
            Class="elevation-1"
            ShowGroupBy>
</MDataTable>

@code {
    public class Dessert
    {
        public string Name { get; set; }

        public string Category { get; set; }

        public string Dairy { get; set; }
    }

    private List<DataTableHeader<Dessert>> _headers = new List<DataTableHeader<Dessert>>
        {
           new ()
           {
            Text= "Dessert (100g serving)",
            Align= DataTableHeaderAlign.Start,
            Value= nameof(Dessert.Name),
            Groupable=false
          },
          new (){ Text= "Category", Value= nameof(Dessert.Category),Align=DataTableHeaderAlign.Start,},
          new (){ Text= "Dairy", Value= nameof(Dessert.Dairy),Align=DataTableHeaderAlign.Start,}
        };

    private List<Dessert> _desserts = new List<Dessert>
        {
           new Dessert
           {
              Name= "Frozen Yogurt",
              Category="Ice cream",
              Dairy="Yes"
            },
            new Dessert
            {
              Name= "Ice cream sandwich",
              Category="Ice cream",
              Dairy="Yes"
            },
            new Dessert
            {
              Name= "Eclair",
              Category="Cookie",
              Dairy="Yes"
            },
            new Dessert
            {
              Name= "Cupcake",
              Category="Pastry",
              Dairy="Yes"
            },
            new Dessert
            {
                Name= "Gingerbread",
                Category="Cookie",
                Dairy="No"
            },
            new Dessert
            {
                Name= "Jelly bean",
                Category="Candy",
                Dairy="No"
            },
            new Dessert
            {
                Name= "Lollipop",
                Category="Candy",
                Dairy="No"
            },
            new Dessert
            {
                Name= "Honeycomb",
                Category="Toffee",
                Dairy="No"
            },
            new Dessert
            {
                Name= "Donut",
                Category="Pastry",
                Dairy="Yes"
            },
            new Dessert
            {
                Name= "KitKat",
                Category="Candy",
                Dairy="Yes"
            }
        };
}